﻿var NewsModel = require(global.rootPath +"/modules/admin/news/js/news");

/* GET home page. */
module.exports = {

	render: function(req, res) {

		var news = global.news,
			pageNum = 5,
			page = (req.params.page || 1) - 1,
			startIndex = page * pageNum,
			endIndex = startIndex + pageNum;

		res.render("run/news", {
			layout: null,
			news: news.slice(startIndex, endIndex),
			pageIndex: page + 1,
			totalCount: Math.ceil(news.length / pageNum)
		});
	},

	renderDetail: function(req, res) {

		var newsModel = new NewsModel();
		var news = newsModel.select(req.params.id);
		res.render("run/newsDetail", {
			layout: null,
			news: news
		});
	}
};